{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###### Content under Creative Commons Attribution license CC-BY 4.0, code under BSD 3-Clause License © 2018 D. Koehn, notebook style sheet by L.A. Barba, N.C. Clementi"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<link href=\"https://fonts.googleapis.com/css?family=Merriweather:300,300i,400,400i,700,700i,900,900i\" rel='stylesheet' >\n",
       "<link href=\"https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,300i,400,400i,700,700i\" rel='stylesheet' >\n",
       "<link href='http://fonts.googleapis.com/css?family=Source+Code+Pro:300,400' rel='stylesheet' >\n",
       "<style>\n",
       "\n",
       "@font-face {\n",
       "    font-family: \"Computer Modern\";\n",
       "    src: url('http://mirrors.ctan.org/fonts/cm-unicode/fonts/otf/cmunss.otf');\n",
       "}\n",
       "\n",
       "\n",
       "#notebook_panel { /* main background */\n",
       "    background: rgb(245,245,245);\n",
       "}\n",
       "\n",
       "div.cell { /* set cell width */\n",
       "    width: 800px;\n",
       "}\n",
       "\n",
       "div #notebook { /* centre the content */\n",
       "    background: #fff; /* white background for content */\n",
       "    width: 1000px;\n",
       "    margin: auto;\n",
       "    padding-left: 0em;\n",
       "}\n",
       "\n",
       "#notebook li { /* More space between bullet points */\n",
       "margin-top:0.5em;\n",
       "}\n",
       "\n",
       "/* draw border around running cells */\n",
       "div.cell.border-box-sizing.code_cell.running { \n",
       "    border: 1px solid #111;\n",
       "}\n",
       "\n",
       "/* Put a solid color box around each cell and its output, visually linking them*/\n",
       "div.cell.code_cell {\n",
       "    background-color: rgb(256,256,256); \n",
       "    border-radius: 0px; \n",
       "    padding: 0.5em;\n",
       "    margin-left:1em;\n",
       "    margin-top: 1em;\n",
       "}\n",
       "\n",
       "\n",
       "div.text_cell_render{\n",
       "    font-family: 'Source Sans Pro', sans-serif;\n",
       "    line-height: 140%;\n",
       "    font-size: 110%;\n",
       "    width:680px;\n",
       "    margin-left:auto;\n",
       "    margin-right:auto;\n",
       "}\n",
       "\n",
       "/* Formatting for header cells */\n",
       ".text_cell_render h1 {\n",
       "    font-family: 'Merriweather', serif;\n",
       "    font-style:regular;\n",
       "    font-weight: bold;    \n",
       "    font-size: 250%;\n",
       "    line-height: 100%;\n",
       "    color: #004065;\n",
       "    margin-bottom: 1em;\n",
       "    margin-top: 0.5em;\n",
       "    display: block;\n",
       "}\t\n",
       ".text_cell_render h2 {\n",
       "    font-family: 'Merriweather', serif;\n",
       "    font-weight: bold; \n",
       "    font-size: 180%;\n",
       "    line-height: 100%;\n",
       "    color: #0096d6;\n",
       "    margin-bottom: 0.5em;\n",
       "    margin-top: 0.5em;\n",
       "    display: block;\n",
       "}\t\n",
       "\n",
       ".text_cell_render h3 {\n",
       "    font-family: 'Merriweather', serif;\n",
       "\tfont-size: 150%;\n",
       "    margin-top:12px;\n",
       "    margin-bottom: 3px;\n",
       "    font-style: regular;\n",
       "    color: #008367;\n",
       "}\n",
       "\n",
       ".text_cell_render h4 {    /*Use this for captions*/\n",
       "    font-family: 'Merriweather', serif;\n",
       "    font-weight: 300; \n",
       "    font-size: 100%;\n",
       "    line-height: 120%;\n",
       "    text-align: left;\n",
       "    width:500px;\n",
       "    margin-top: 1em;\n",
       "    margin-bottom: 2em;\n",
       "    margin-left: 80pt;\n",
       "    font-style: regular;\n",
       "}\n",
       "\n",
       ".text_cell_render h5 {  /*Use this for small titles*/\n",
       "    font-family: 'Source Sans Pro', sans-serif;\n",
       "    font-weight: regular;\n",
       "    font-size: 130%;\n",
       "    color: #e31937;\n",
       "    font-style: italic;\n",
       "    margin-bottom: .5em;\n",
       "    margin-top: 1em;\n",
       "    display: block;\n",
       "}\n",
       "\n",
       ".text_cell_render h6 { /*use this for copyright note*/\n",
       "    font-family: 'Source Code Pro', sans-serif;\n",
       "    font-weight: 300;\n",
       "    font-size: 9pt;\n",
       "    line-height: 100%;\n",
       "    color: grey;\n",
       "    margin-bottom: 1px;\n",
       "    margin-top: 1px;\n",
       "}\n",
       "\n",
       "    .CodeMirror{\n",
       "            font-family: \"Source Code Pro\";\n",
       "\t\t\tfont-size: 90%;\n",
       "    }\n",
       "/*    .prompt{\n",
       "        display: None;\n",
       "    }*/\n",
       "\t\n",
       "    \n",
       "    .warning{\n",
       "        color: rgb( 240, 20, 20 )\n",
       "        }  \n",
       "</style>\n",
       "<script>\n",
       "    MathJax.Hub.Config({\n",
       "                        TeX: {\n",
       "                           extensions: [\"AMSmath.js\"], \n",
       "                           equationNumbers: { autoNumber: \"AMS\", useLabelIds: true}\n",
       "                           },\n",
       "                tex2jax: {\n",
       "                    inlineMath: [ ['$','$'], [\"\\\\(\",\"\\\\)\"] ],\n",
       "                    displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"] ]\n",
       "                },\n",
       "                displayAlign: 'center', // Change this to 'center' to center equations.\n",
       "                \"HTML-CSS\": {\n",
       "                    styles: {'.MathJax_Display': {\"margin\": 4}}\n",
       "                }\n",
       "        });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Execute this cell to load the notebook's style sheet, then ignore it\n",
    "from IPython.core.display import HTML\n",
    "css_file = '../style/custom.css'\n",
    "HTML(open(css_file, \"r\").read())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Seismic wave propagation in linear-elastic media\n",
    "\n",
    "I will shortly review the eqations of motion to describe wave propagation in linear-elastic media. A detailed derivation of the governing equations is described in chapter 2 of the Lecture notes:\n",
    "\n",
    "[\"Theory of elastic waves\" by Gerhard Müller](https://www.geo.uni-hamburg.de/geophysik/studium/bsc-geophysik-ozeanographie/module/vertiefung-geophysik/vgsw/seismicwaves-mueller2013.pdf)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Linear-elastic equations of motion\n",
    "\n",
    "Our aim is to find a simple mathematical model, that is able to describe seismic wave propagation in the subsurface, including body waves, surface waves and converted waves. At first glance, this seem to be an impossible task, however as physicists we can rely on the fundamental principles of conservation of mass, momentum and energy to describe the physics of a complex problem. **Conservation of momentum** in a continuous medium  can be described by\n",
    "\n",
    "\\begin{equation}\n",
    "\\rho \\frac{\\partial^2 u_i}{\\partial t^2} = \\sum_{j=1}^{3} \\frac{\\partial}{\\partial x_j} \\sigma_{ij} + f_i\n",
    "\\end{equation}\n",
    "\n",
    "with\n",
    "\n",
    "\\begin{align}\n",
    "u_i &= displacement, \\nonumber\\\\\n",
    "\\sigma_{ij} &= stress\\; tensor, \\nonumber\\\\\n",
    "t &= time, \\nonumber\\\\\n",
    "x_i &= spatial\\; coordinates,\\; e.g. (x_1,x_2,x_3)\\; :=\\; (x,y,z), \\nonumber\\\\\n",
    "\\rho &= density. \\nonumber\\\\\n",
    "\\end{align}\n",
    "\n",
    "This system of partial differential equations simply states that we can change the momentum in the medium (LHS) using surface forces described by the symmetric stress tensor $\\sigma_{ij}$ or body forces $f_i$ (RHS). \n",
    "\n",
    "An alternative interpretation of eq. (1) is that the momentum in the medium can be changed either by the interaction of particles on the atomic scale or by introducing a momentum source term $f_i$. For seismic waves such a source term could be a hammer blow, explosion or earthquake.\n",
    "\n",
    "The stress tensor $\\sigma_{ij}$ describes the action of general surface forces $\\bf{T}$ in $x_1,x_2$ and $x_3$ direction on a small volume of our medium.\n",
    "\n",
    "<img src=\"images/stress_tensor_final.png\" style=\"width: 800px;\"/>\n",
    "\n",
    "These equations are independent of the medium state, i.e. if it is a liquid, solid or gas. Therefore, additional equations are required to describe how the medium is deformed, when a certain amount of stress is applied to the medium.\n",
    "\n",
    "For the solid earth, we assume that the medium behaves similar to a simple spring ... \n",
    "\n",
    "<img src=\"images/Hookes-law-springs.png\" style=\"width: 600px;\"/>\n",
    "\n",
    "If a certain amount of force is applied to the spring it will result in a displacement x. If twice the amount of force is applied, the displacement will also become twice as large. Therefore, we have a linear relation between the force applied to the spring and the resulting displacement of the spring.\n",
    "\n",
    "At a point far away from the source of a seismic wave, where the displacements of the earth $u_i$ are small, we can make a similar assumption. However, compared to the simple spring the forces in our 3D medium can act in an arbritary direction, resulting in an an arbritary deformation of the medium. To accurately describe this behaviour, we are using a relation between the stress $\\sigma_{ij}$ and medium deformation $\\epsilon_{ij}$ governed by a linear relationship known as the **generalized Hookes law**:\n",
    "\n",
    "\n",
    "\\begin{equation}\n",
    "\\sigma_{ij} = \\sum_{k=1}^{3}\\sum_{l=1}^{3} c_{ijkl}\\; \\epsilon_{kl},\n",
    "\\end{equation}\n",
    "\n",
    "\n",
    "where the deformation tensor \n",
    "\n",
    "\n",
    "\\begin{equation}\n",
    "\\epsilon_{ij} = \\frac{1}{2}\\biggl(\\frac{\\partial u_i}{\\partial x_j} + \\frac{\\partial u_j}{\\partial x_i}\\biggr) \\nonumber\n",
    "\\end{equation}\n",
    "\n",
    "\n",
    "describes the deformation state. Notice the symmetry of the strain-tensor \n",
    "\\begin{equation}\n",
    "\\epsilon_{ij} = \\epsilon_{ji} \\nonumber\n",
    "\\end{equation}\n",
    "\n",
    "The 4th order **elastic tensor** $\\mathbf c_{ijkl}$ has 81 (= 9 x 9 components). Due to the symmetry of the stress- and strain tensors only 36 (=\n",
    "6 x 6) components are independent. Since the elastic deformation energy (= elastic\n",
    "energy per volume unit) is a state function, the number of components can be further reduced to 21 (Aki and Richards (1980), p.21-23). This is the maximum number of independent elasticity constants, which an anisotropic linear-elastic medium can have.\n",
    "\n",
    "To introduce a simpler notation, I neglected the fact that the wavefields $v_i$, $\\sigma_{ij}$ depend on the spatial coordinate $x_i$ and time $t$ in the above equations. The material parameters $\\rho$, $c_{ijkl}$ are assumed in most cases only depend on spatial, but no temperal variations. \n",
    "\n",
    "This simple system of partial differential equations (1) + (2), together with certain initial and boundary conditions, is all we need to describe the propagation of a seismic wavefield in a linear-elastic medium. This includes, body waves, surface waves, (multiple) reflected waves, refracted waves, diffracted waves, P-S or S-P converted waves ... if I have to bet who can predict the arrival time and amplitude of a seismic wavefield more accurately, a physicist or a fortuneteller, I would bet on the physicist. Think about it for a moment, eq. (1) + (2) allows to predict the future!\n",
    "\n",
    "The only requirement is that we know the distribution of the density $\\rho$ and elastic tensor components $c_{ijkl}$ in the sub-surface. Then we can solve the partial differential equations either analytical or numerically. You will learn how to do this in the upcoming lectures."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Topics of the lecture\n",
    "\n",
    "To implement all topics described in [Lecture 0 - Overview](https://danielkoehnsite.files.wordpress.com/2020/04/lect_00_overview_tew2-2.pdf),\n",
    "we actually only need to modify some small parts of eqs. (1) + (2):\n",
    "\n",
    "* To solve eqs. (1) + (2) numerically we have to discretize the material parameters and wavefields on a Cartesian grid and replace the partial differential operators by **Finite Difference** operators \n",
    "* **Seismic anisotropy** is already described by the elastic tensor $c_{ijkl}$ , we only have to understand the impact of the different tensor components on the seismic wavefield\n",
    "* To implement **visco-elastic damping**, we need to modify eq.(2), the elastic tensor components and add some additional partial differential equations\n",
    "* To model **frequency domain wavefields**, we can either apply a discrete Fourier transform to the modelled time domain wavefields, or we fourier transform eq.(1)\n",
    "* **Global seismic wave propagation** requires a transformation from the Cartesian to a spherical coordinate system. This affects only the spatial derivatives in eq.(1) and the deformation tensor $\\epsilon_{ij}$, but not eq.(2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Some other notations\n",
    "\n",
    "Physicists are known to be lazy, so I introduce some simpler notations for eq.(1) + (2). First, we can get rid of the summations by introducing the [Einstein notation](https://en.wikipedia.org/wiki/Einstein_notation), where repeated indices are assumed as summation. For example, the product of a (m x n) matrix $a_{ij}$ with a (n x 1) column vector $x_j$\n",
    "\n",
    "\\begin{align}\n",
    "g_i = \\sum_{j=1}^n a_{ij} x_j\\; (i=1,2,...,m)\\nonumber\n",
    "\\end{align}\n",
    "\n",
    "can be written with Einstein notation as \n",
    "\n",
    "\\begin{align}\n",
    "g_i = a_{ij} x_j\\nonumber\n",
    "\\end{align}\n",
    "\n",
    "Therefore, we can write eqs. (1) + (2) as\n",
    "\n",
    "\\begin{align}\n",
    "\\rho \\frac{\\partial^2 u_i}{\\partial t^2} &= \\frac{\\partial}{\\partial x_j} \\sigma_{ij} + f_i \\nonumber \\\\\n",
    "\\sigma_{ij} &= c_{ijkl}\\; \\epsilon_{kl} \\nonumber\n",
    "\\end{align}\n",
    "\n",
    "where the Einstein notation has to be applied twice in the stress-strain relationship. Alternatively, we could use vector notation:\n",
    "\n",
    "\\begin{align}\n",
    "\\rho \\frac{\\partial^2 \\mathbf{u}}{\\partial t^2} &= \\mathbf{\\nabla} \\cdot \\mathbf{\\sigma} + \\mathbf{f} \\nonumber \\\\\n",
    "\\mathbf \\sigma &= \\mathbf{c} : \\mathbf \\epsilon \\nonumber \\\\\n",
    "\\mathbf \\epsilon &= \\frac{1}{2}\\biggl(\\mathbf{\\nabla\\; u} + (\\mathbf{\\nabla\\; u})^T\\biggr) \\nonumber\n",
    "\\end{align}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## We learned:\n",
    "\n",
    "* Linear-elastic equations of motion\n",
    "* What parts of the forward problem we will change during the course of this lecture\n",
    "* Alternative notations for the linear-elastic equations of motion"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## References\n",
    "\n",
    "1. [\"Theory of elastic waves\" lectures notes by Gerhard Müller](https://www.geo.uni-hamburg.de/geophysik/studium/bsc-geophysik-ozeanographie/module/vertiefung-geophysik/vgsw/seismicwaves-mueller2013.pdf) (2007) edited by Michael Weber, Georg Rümpker and Dirk Gajewski. \n",
    "2. _Quantitative Seismology_ (1980). Keiiti Aki and Paul G. Richards. \n"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  },
  "widgets": {
   "state": {},
   "version": "1.1.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
